import Vue from 'vue'
import VueRouter from 'vue-router'
import HomeView from '../views/HomeView.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/homes' // 将根路径重定向到 /homes
  },
  {
    path: '/',
    name: 'home',
    component: HomeView,
    children:
    [
      {
        path: 'courseVideo',
        name: '课程播放',
        component: () => import('@/views/courseVideo/CourseVideo.vue')
      },
      // 马佳乐 首页路由
      {
        path: '/homes',
        name: 'homes',
        component: () => import('@/views/home/home.vue'),
        meta: {
          requireAuth: false
        }
      },
      // 马佳乐 模糊查询页面路由
      {
        path: '/search',
        name: 'search',
        component: () => import('@/views/search/search.vue'),
        meta: {
          requireAuth: true
        }
      },
      // 马佳乐 直播页面路由
      { path: '/ListLive', name: 'ListLive', component: () => import('@/views/live/ListLive.vue') },
      // 闫星宇 选课页面
      {
        path: '/purchasecourses',
        name: 'Purchasecourses',
        component: () => import('../views/purchasecourses/Purchasecourses.vue'),
        meta: {
          requireAuth: true
        }
      },
      // // 闫星宇
      // {
      //   path: '/confirm',
      //   name: 'Confirm',
      //   component: () => import('@/views/confirm/Confirm.vue'),
      //   meta: {
      //     requireAuth: true
      //   }
      // },
      // 闫星宇 买课页面
      { path: '/confirm', name: 'Confirm', component: () => import('@/views/confirm/Confirm.vue') },
      // 闫星宇 开通会员页面
      { path: '/memberplacing', name: 'Memberplacing', component: () => import('@/views/memberplacing/Memberplacing.vue') },
      // 闫星宇 系列课程页面
      { path: '/seriescourses', name: 'Seriescourses', component: () => import('@/views/seriescourses/Seriescourses.vue') },
      // 闫星宇 系列课程：参加全部课程页面
      { path: '/confirmorder', name: 'Confirmorder', component: () => import('@/views/confirmorder/Confirmorder.vue') },
      // 闫星宇 会员中心页面
      { path: '/hmember', name: 'Hmember', component: () => import('@/views/hmember/Hmember.vue') },
      // 王旭 支付成功路由
      { path: '/payForOrders', name: 'payForOrders', component: () => import('@/views/payForOrders/PayForOrders.vue') },
      {
        // 杨友朋 个人中心路由
        path: '/PersonalManage',
        name: 'PersonalManage',
        component: () => import('@/views/personal/PersonalManage.vue'),
        children:
        [
          // 杨友朋 收藏
          { path: '/Collection', name: 'Collection', component: () => import('@/views/personal/Collection.vue') },
          // 杨友朋 订单
          { path: '/Order', name: 'Order', component: () => import('@/views/personal/Order.vue') },
          // 杨友朋 个人信息
          { path: '/PersonalInfo', name: 'PersonalInfo', component: () => import('@/views/personal/PersonalInfo.vue') },
          // 杨友朋 课程表
          { path: '/Timetable', name: 'Timetable', component: () => import('@/views/personal/Timetable.vue') },
          // 杨友朋 用户安全
          { path: '/UserSecurity', name: 'UserSecurity', component: () => import('@/views/personal/UserSecurity.vue') },
          // 杨友朋 会员中心
          { path: '/VipCenter', name: 'VipCenter', component: () => import('@/views/personal/VipCenter.vue') }
        ]
      }
    ]
  },
  // 马佳乐 直播页面路由
  { path: '/liveDetail', name: 'liveDetail', component: () => import('@/views/live/LiveDetail.vue') }
]

// const router = new VueRouter({
//   routes
// })

// export default router

const router = new VueRouter({
  // mode: 'history',
  scrollBehavior (to, from, savePosition) {
    return { x: 0, y: 0 }
  },
  routes
})

export default router
